package lab03.test01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by Administrator on 2017-11-15.
 */
public class InputStreamTest {
    public static void main(String[] args) {

        // 字节流读文件 InputStream
        try {
            FileInputStream fileInputStream =
                    new FileInputStream("E:\\1.txt");


            // 一次读一个字节
            int current;
            while ((current = fileInputStream.read()) != -1) {
                System.out.print((char) current);
            }

            // 一次读多个字节
            byte[] data = new byte[1024];
            while (fileInputStream.read(data) != -1) {

                System.out.println(data);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
